<% if @concept.mappings.empty? %>
  <span class="info">No mappings exist.</span>
<% else %>
  <table>
    <tr>
      <th></th>
      <th>Relationship</th>
      <th>Local Name</th>
      <th>Local Key</th>
      <th>Comments</th>
      <th>Attributes</th>
      <th>Mapped By</th>
      <th>Creation Date</th>      
    </tr>
    <% for concept in @concept.mappings %>
      <% mapping_details = @concept.mapping_details_for concept %>
      <% for mapping_detail in mapping_details %>
        <tr class="<%= cycle "even", "odd" %>">
          <td><%= link_to_remote "Destroy", :update => "concept_mappings", :url => {:controller => "concept", :action => "destroy_map", :concept_id_1 => @concept.id, :concept_id_2 => concept.id, :mapping_type_id => mapping_detail.mapping_type_id} %></td>
          <td><%= h mapping_detail.mapping_type.name %></td>
          <td><%= h concept.name %></td>
          <td><%= h concept.local_key %></td>
          <td class="comment_cell"><div><%= h mapping_detail.comments %></div></td>
          <td>
            <table>
              <tr>
                <% concept.attrs.each do |attr| %>
                  <th><%= attr.name %></th>
                <% end %>
              </tr>
              <tr class="even">
                <% concept.attrs.each do |attr| %>
                  <td><%= attr.value %></td>
                <% end %>
              </tr>
            </table>
          </td>
          <td><%= h mapping_detail.user.fullname %></td>
          <td><%= pretty_time mapping_detail.created_at %></td>
        </tr>
      <% end %>
    <% end %>
  </table>
<% end %>